////////////////////////////////////////////////////////////////////////////////

#ifndef _WIDGET_H_
#define _WIDGET_H_

#ifndef _GRAPHICS_H_
#include "graphics.h"
#endif

#include <boost/scoped_ptr.hpp>
#include <vector>

////////////////////////////////////////////////////////////////////////////////

/** Base class for widgets
*
*  @author   Anastasia Karpinska
*  @since    May 29th, 2010
*  @updated  May 29th, 2010
*/
class Widget
{
////////////////////////////////////////////////////////////////////////////////

public:


    /** Constructor */
    Widget( Widget* _parent = NULL );


    /** Constructor */
    Widget( int _w, int _h, Graphics::Object _obj, Widget* _parent = NULL );


    /** Constructor */
    Widget( int _w, int _h, int _x, int _y, Graphics::Object _obj, Widget* _parent = NULL );


    /** Resize widget */
    void Resize();


    /** Key change handler */
    virtual void OnKeyChanged() = 0;


    /** Mouse position change handler */
    virtual void OnMousePositionChanged( int _x, int _y  ) = 0;


////////////////////////////////////////////////////////////////////////////////


    /** Returns X position of widget */
    inline int X() { return m_X; };


    /** Returns Y position of widget */
    inline int Y() { return m_Y; };


    /** Returns widget's width */
    inline int W() { return m_Width; };


    /** Returns widget's height */
    inline int H() { return m_Height; };


    /** Returns absolute X position of widget */
    inline int AbsX() { return m_AbsX; };


    /** Returns absolute Y position of widget */
    inline int AbsY() { return m_AbsY; };



////////////////////////////////////////////////////////////////////////////////

private:


    /** Widget's width */
    int m_Width;


    /** Widget's height */
    int m_Height;


    /** X position on parent widget */
    int m_X;


    /** Y position on parent widget */
    int m_Y;


    /** Absolute X position */
    int m_AbsX;


    /** Absolute Y position */
    int m_AbsY;


    /** Widget object */
    Graphics::Object m_Object;


    /** Parent widget pointer */
    Widget* m_Parent;


////////////////////////////////////////////////////////////////////////////////

};

////////////////////////////////////////////////////////////////////////////////


/** Scoped pointer for widgets, uses for child widgets in widgets tree */
typedef boost::scoped_ptr<Widget> WidgetAutoPtr;


/** Type for widgets collection */
typedef std::vector<Widget*> WidgetsVec;


////////////////////////////////////////////////////////////////////////////////

#endif
